{% extends "base.html" %}

{% block title %}
    {{ post.title }}
{% endblock %}

{% block content %}
    <h1>{{ post.title }}</h1>
    <p class="date">
        Published {{ post.publish }} by {{ post.author }}
    </p>

    {{ post.body|linebreaks }}
    <p>
        <a href="{% url 'blog:post_share' post.id %}">
            分享这篇文章
        </a>
    </p>
    {% for comment in comments %}
        <div class="comment">
            <p class="info">
                这是第{{ forloop.counter }}个评论，来自于{{ comment.name }}
                {{ comment.created }}
            </p>
            {{ comment.body }}
        </div>
    {% empty %}
        <p>当前文章没有评论！</p>
    {% endfor %}

    {% if new_comment %}
        <h2>你的新评论已经添加</h2>
    {% else %}
        <h2>添加一个新的评论</h2>
        <form action="" method="post">
            {{ comment_form.as_p }}
            {% csrf_token %}
            <p><input type="submit" value="添加评论"></p>
        </form>
    {% endif %}
{% endblock %}